﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ProjektXNA
{
    class Enemy : Sprite
    {
        protected int hp;
        protected int hpNow;
        protected bool isDead = false;

        //protected int armor;
        protected float moveSpeed;
        protected int moneyDrop;

        public int HpNow
        {
            get { return hpNow; }
            set { hpNow = value; }
        }

        public bool IsDead
        {
            get { return hpNow <= 0; }
        }

        public int MoneyDrop
        {
            get { return moneyDrop; }
        }

        public Enemy(Texture2D texture, Vector2 position, int hp, int moneyDrop, float speed)
            : base(texture, position)
        {
            this.hp = hp;
            this.hpNow = this.hp;
            this.moneyDrop = moneyDrop;
            this.moveSpeed = speed;
        }

        public override void Update(GameTime gameTime)
        {
            if (hpNow <= 0)
                isDead = true;

            base.Update(gameTime);
        }


        /// <summary>
        /// Rita sak
        /// </summary>
        /// <param name="spriteBatch"></param>

        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!isDead)
            {
                float hpPercentage = (float)hpNow / (float)hp;

                Color color = new Color(new Vector3(1 - hpPercentage, 1 - hpPercentage, 1 - hpPercentage));

                base.Draw(spriteBatch, color);
            }
        }
    }
}
